package io.adrainty.bolee.security.feign;

import io.adrainty.bolee.framework.commons.basic.ResultDTO;
import io.adrainty.bolee.framework.commons.user.DataSecurityEntity;
import io.adrainty.bolee.framework.commons.user.UserEntity;
import io.adrainty.bolee.security.hystrix.UserFeignHystrix;
import io.adrainty.bolee.security.models.entity.ResourceEntity;
import io.adrainty.bolee.security.models.entity.RoleEntity;
import io.adrainty.bolee.security.models.request.QueryDataSecurityDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * <p>ICustomerFeign</p>
 *
 * @author AdRainty
 * @version V1.0.0
 * @description ICompanyFeign
 * @since 2025/8/5 00:17:35
 */


@FeignClient(value = "security-web", path = "/user-feign", fallback = UserFeignHystrix.class)
public interface IUserFeign {

    /**
     * 按照客户查找用户
     *
     * @param username 用户名
     * @param company  公司
     * @return 用户
     */
    @PostMapping("/username-login/{username}/{company}")
    ResultDTO<UserEntity> usernameLogin(@PathVariable("username") String username, @PathVariable("company") String company);

    /**
     * 按照手机号查找用户
     *
     * @param mobile  手机号
     * @param company 公司
     * @return 用户
     */
    @PostMapping("/mobile-login/{mobile}/{company}")
    ResultDTO<UserEntity> mobileLogin(@PathVariable("mobile") String mobile, @PathVariable("company") String company);

    /**
     * 微信登录
     *
     * @param openId  微信openId
     * @param company 公司
     * @return 用户
     */
    @PostMapping("/wechat-login/{openId}/{company}")
    ResultDTO<UserEntity> wechatLogin(@PathVariable("openId") String openId, @PathVariable("company") String company);

    /**
     * 查找用户所有角色
     *
     * @param userId 用户ID
     * @return 用户
     */
    @PostMapping("/find-role-user/{userId}")
    ResultDTO<List<RoleEntity>> findRoleByUserId(@PathVariable("userId") Long userId);

    /**
     * 查找用户所有资源
     *
     * @param userId 用户ID
     * @return 资源列表
     */
    @PostMapping("/find-resource-user/{userId}")
    ResultDTO<List<ResourceEntity>> findResourceByUserId(@PathVariable("userId") Long userId);

    /**
     * 获取用户数据权限
     *
     * @param queryDataSecurityVO 查询参数k
     * @return 数据权限
     */
    @PostMapping(value = "/user-data-security")
    ResultDTO<DataSecurityEntity> userDataSecurity(@RequestBody QueryDataSecurityDTO queryDataSecurityVO);

    /**
     * 查询用户
     *
     * @param userId 用户ID
     * @return 用户信息
     */
    @PostMapping(value = "/find-user-by-id")
    ResultDTO<UserEntity> findUserById(@RequestParam("userId") Long userId);

}
